/*
 * Chat Functions
 * 
 * functions that will make calls to chat ajax files
 * 
 * @author : Jason Meulenhoff
 * @mail : mail@kacangboi.com
 * @web : http://kacangboi.com
 * @copyright : KacangNetworks 2010
 * 
 */

function retrieveMessage()
{
	ajaxRequest("../ajax/readchat.ajax.php","command=read",append);
	setTimeout(retrieveMessage,1000); // 5 second time out
}

function insertMessage(message,author)
{
	if(message.length <= 0)
		append("<span style='font-size : 13px;'>You did not type any message</span><br/>");
	else
		ajaxRequest("../ajax/sendchat.ajax.php","command=send&message="+escape(message)+"&author="+author+"",onComplete)
}

function onComplete(oReq)
{
	if(oReq != "100100100")
	{
		$('#messagehere').prepend(oReq);
		$('#message').val("");
	}
	else
		$('#messagehere').prepend('<span style="font-size : 13px;">This chat function requires 2 seconds to wait before posting a new message</span><br/>');
}

function append(oreq)
{
	$('#messagehere').prepend(oreq);
}